package com.example.design.patterns.冰河.行为模式.观察者模式.concreteSubject;

import com.example.design.patterns.冰河.行为模式.观察者模式.observer.Policeman;
import com.example.design.patterns.冰河.行为模式.观察者模式.subject.Citizen;

/**
 * ConcreteSubject(具体目标)将有关状态存入各 ConcreteSubject对象.
 * 当它的状态发生改变时,向其观察者发出通知
 */
public class TianHeCitizen extends Citizen {
    public TianHeCitizen(Policeman policeman) {
        this.setPolicemen();
        this.register(policeman);
    }

    /**
     *
     * @param help
     */
    @Override
    public void sendMessage(String help) {
        this.setHelp(help);
        for (int i = 0; i < pols.size(); i++) {
            Policeman pol = pols.get(i);
            //通知警察行动
            pol.action(this);

        }
    }
}
